package com.baizhi.rjb.Controller;

import com.baizhi.rjb.entity.Admin;
import com.baizhi.rjb.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;
@Controller
@RequestMapping("/admin")
@CrossOrigin
public class AdminController {

    @Autowired
    private AdminService adminService;
    //获取验证码
    @RequestMapping("/getImageCodes")
    @ResponseBody
    Map<String,String> getImageCodes(){
//        Map<String,String> map = new HashMap<String,String>();
        return adminService.getImageCodes();
    }
    //登录
    @RequestMapping("/login")
    @ResponseBody
    Map<String,String> login(@RequestBody Admin admin,String token){
        return adminService.login(admin,token);
    }
    //获取登录用户信息
    @RequestMapping("/getUserInfo")
    @ResponseBody
    public Admin getUserInfo(String token){

        return adminService.getUserInfo(token);
    }
    //退出
    @RequestMapping("/logout")
    @ResponseBody
    void logout(String token){
        adminService.logout(token);
    }
}
